<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link href="<?php echo base_url("asseet/image/favicon.png"); ?>" rel="shortcut icon" />
        <title>Halaman Masuk | Sistem Informasi SMAN 1 SUKABUMI</title>
        <link rel="stylesheet" href="<?php echo base_url("data/style/admin/css/style.default.css") ?>" type="text/css" />
        <script type="text/javascript" src="<?php echo base_url("data/style/admin/js/jquery-1.9.1.min.js") ?>"></script>
        <script type="text/javascript" src="<?php echo base_url("data/style/admin/js/jquery-migrate-1.1.1.min.js") ?>"></script>
        <script type="text/javascript" src="<?php echo base_url('data/style/admin/js/bootstrap.min.js') ?>"></script>
    </head>
    <body class="loginbody">
    <div class="loginwrapper">
        <div class="loginwrap zindex100 animate2 bounceInDown">
            <h1 class="logintitle">
                <span class="iconfa-lock"></span> Masuk <span class="subtitle">Masukkan username dan password anda</span></h1>
            <div class="loginwrapperinner">
                <form id="loginform" action="" method="post">
					<div id="message" style="display: none;"></div>
                    <p class="animate4 bounceIn">
                        <input type="text" id="username" name="username" placeholder="Username" autocomplete="off" autofocus="autofocus" />
                    </p>
                    <p class="animate5 bounceIn">
                        <input type="password" id="password" name="password" placeholder="Password" autocomplete="off" />
                    </p>
                    <p class="animate6 bounceIn">
                        <button id="submit" class="btn btn-default btn-block">Masuk</button>
                    </p>
                </form>
            </div><!--loginwrapperinner-->
        </div>
        <div class="loginshadow animate3 fadeInUp"></div>
    </div><!--loginwrapper-->

    <script type="text/javascript">
        jQuery.noConflict();

        jQuery(document).ready(function() {

            var anievent = (jQuery.browser.webkit) ? 'webkitAnimationEnd' : 'animationend';
            jQuery('.loginwrap').bind(anievent, function() {
                jQuery(this).removeClass('animate2 bounceInDown');
            });

            jQuery('#username,#password').focus(function() {
                if (jQuery(this).hasClass('error'))
                    jQuery(this).removeClass('error');
            });

            jQuery('#loginform button#submit').click(function() {
                if (!jQuery.browser.msie) {
                    if (jQuery('#username').val() === '' || jQuery('#password').val() === '') {
                        if (jQuery('#username').val() === '')
                            jQuery('#username').addClass('error');
                        else
                            jQuery('#username').removeClass('error');
                        if (jQuery('#password').val() === '')
                            jQuery('#password').addClass('error');
                        else
                            jQuery('#password').removeClass('error');
                        jQuery('.loginwrap').addClass('animate0 wobble').bind(anievent, function() {
                            jQuery(this).removeClass('animate0 wobble');
                        });
                    } else {
                        jQuery('#loginform').submit();
                    }
                    return false;
                }
            });
			
		jQuery('#loginform').submit(function(eve) {
                eve.preventDefault();

                jQuery.ajax({
                    url: "<?php echo site_url("admin/login/proses_login") ?>",
                    type: "POST",
                    dataType: "html",
                    data: jQuery(this).serialize(),
                    beforeSend: function() {
                    },
                    success: function(html) {
                        // alert(html);
                        if (html === "OK")
                        {
                             jQuery('.loginwrapper').addClass('animate0 fadeOutUp').bind(anievent, function() {
                                 window.location.replace("<?php echo site_url($_SERVER['PATH_INFO']) ?>");
                             });
                        }
                        else
                        {
                            jQuery('#message').html(html).fadeIn('slow');
                            jQuery('#password').val('');
                        }
                    }
                });
            });
        });
    </script>
</body>
</html>